﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Skynet.WebAdministracion.Views.CategoriesMgm;
using Microsoft.Practices.Unity;

namespace SkynetSite.Administration
{
    public partial class MgmCategories : Infrastructure.Web.Views.Page ,  ICategoriesMgmView
    {
        private CategoriesMgmAzurePresenter _Presenter;

        [Dependency]
        public CategoriesMgmAzurePresenter Presenter
        {
            get { return _Presenter; }
            set { 
                _Presenter = value;
                this._Presenter.View = this; 
            }
        }       
        protected void Page_Load(object sender, EventArgs e)
        {
            this.ODSCategories.ObjectCreating += DataSource_ObjectCreating;
            this.ODSWorkCategory.ObjectCreating += DataSource_ObjectCreating;
            if (!Page.IsPostBack)
            {
                this.Presenter.OnViewInitialized();  
            }
            this.Presenter.OnViewLoaded();
        }
        protected void DataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = this.Presenter;  
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DetailsView1.ChangeMode(DetailsViewMode.Edit);
        }
    }
}